var currentPage = 1;
var pageSize = 10;
var totalPage = 1;
var totalCount = 0;

function showLieBiao() {

    $(".daibanbiao").find("tr:gt(0)").find("td").html("&nbsp;");
    let name = $(".name").val();
    let inputtingTime = $(".inputtingTime").val();
    console.log(name)
    console.log(inputtingTime)
    let json={
        name:name,
        inputtingTime:inputtingTime,
        pageNum:currentPage,
        pageSize:pageSize
    }
    $.ajaxSettings.async=false;
    $.getJSON("/selAll",json,function (data) {
        console.log(data)
        totalPage=data.pages;
        totalCount=data.total
        $(data.list).each(function (i,v) {
            $(".daibanbiao").find("tr").eq(i+1).find("td").eq(0).text((currentPage-1)*pageSize+i+1);
            $(".daibanbiao").find("tr").eq(i+1).find("td").eq(1).text(v.filestatus);
            $(".daibanbiao").find("tr").eq(i+1).find("td").eq(2).text(v.name+"档案");
            $(".daibanbiao").find("tr").eq(i+1).find("td").eq(3).text(v.inputtingtime);
            $(".daibanbiao").find("tr").eq(i+1).find("td").eq(4).html('<div class="">' +
                '<a href="/人事档案合2/'+v.personnelid+'" class="layui-btn layui-btn-xs ">'+'复核'+'</a>'+
                '<a href="/人事档案明细2/'+v.personnelid+'" class="layui-btn layui-btn-xs ">'+'明细'+'</a>'+
                '</div>');

        })
    },"json")
    $.ajaxSettings.async=true;
    showPage()
}
function first() {
    currentPage = 1 ;
    showLieBiao();
}
function showPage() {
    $("#showPage").text(currentPage + " / " + totalPage );
}
function prev() {
    currentPage--;
    if(currentPage < 1){
        currentPage = 1;
        return;
    }
    showLieBiao();
}

function next() {
    currentPage++;
    if(currentPage > totalPage){
        currentPage = totalPage;
        return;
    }
    showLieBiao();
}

function end() {
    currentPage = totalPage;
    showLieBiao();
}

function seLike() {
    //防止出现2/1 的情况
    currentPage = 1;
    //反页查看数据
    showLieBiao();
    //判断防止“0数据”，出现1/0的情况！收尾工作
    if (totalCount == 0 ){
        totalPage = 1;
        alert("抱歉，未找到符合条件的数据")
    }
}

//复核
function fuhe2(thisA) {
    let personnelid = $("#personnelid").val()
    // alert(personnelid)
    let department = $(".department").val();
    let status = $(".status").val();
    let position = $(".position").val();
    let positionid = $(".positionid").val();
    let name = $(".name").val();
    let sex = $(".sex").val();
    let email = $(".email").val();
    let pohone = $(".pohone").val();
    let address = $(".address").val();
    let cardid = $(".cardid").val();
    let originalHome = $(".originalHome").val();
    let politicsStatus = $(".politicsStatus").val();
    let school = $(".school").val();
    let specialty = $(".specialty").val();
    let educationBackground = $(".educationBackground").val();
    let salary = $(".salary").val();
    let openingBank = $(".openingBank").val();
    let cardNumbers = $(".cardNumbers").val();
    let socialNumbers = $(".socialNumbers").val();
    let registrant = $(".registrant").val();
    let inputtingTime = $(".inputtingTime").val();
    let curriculumVitae = $(".curriculumVitae").val();
    let FamilyInformation = $(".FamilyInformation").val();
    let comment = $(".comment").val();
    let attachment = $(".attachment").val();
    let modification = $(".modification").val();

    let fuhe = "审核通过"
    // if (modification ==""){
    //     alert("请填写变更类型！")
    // }

    let json = {
        personnelid:personnelid,
        department:department,
        position:position,
        status:status,
        positionid:positionid,
        name:name,
        sex:sex,
        email:email,
        pohone:pohone,
        address:address,
        cardid:cardid,
        originalHome:originalHome,
        politicsStatus:politicsStatus,
        school:school,
        specialty:specialty,
        educationBackground:educationBackground,
        salary:salary,
        openingBank:openingBank,
        cardNumbers:cardNumbers,
        socialNumbers:socialNumbers,
        registrant:registrant,
        inputtingTime:inputtingTime,
        curriculumVitae:curriculumVitae,
        FamilyInformation:FamilyInformation,
        comment:comment,
        attachment:attachment,
        modification:modification,
        fuhe:fuhe
    }
    $.ajaxSettings.async =false;
    $.getJSON("/fuhe3",json,function (data) {
        if (data == true){
            $(thisA).parent("tr").remove();
            alert("复核通过！")
            location.href = "/待办列表";
        }
    })
    $.ajaxSettings.async =true;
}


